package com.cjk.foundation.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.cjk.foundation.entity.RoleEntity;

@Repository
public interface RoleDao {
	
	public List<RoleEntity> selectListByCondition(@Param("page") Integer page, @Param("pageSize") Integer pageSize);
	
	public Integer selectCountByCondition();
	
	public void insert(RoleEntity roleEntity);
	
	@Select("select role_name from role where id = #{roleId}")
	public String selectRoleName(@Param("roleId") Integer roleId);
	
	@Update("update role set role_name = #{name} where id = #{id}")
	public void update(@Param("name") String name, @Param("id") Integer id);
	
	@Update("delete from role where id = #{id}")
	public void deleteById(@Param("id") Integer id);
	
	@Select("select COUNT(*) from employee where role_id = #{id}")
	public Integer countRoleInUsed(@Param("id") Integer id);
	
	public Integer checkExist(@Param("name") String name, @Param("id") Integer id);

}
